package bupt.xixi.learning.test.bean;

import lombok.extern.slf4j.Slf4j;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

@Slf4j
public class UserServiceInterceptor implements MethodInterceptor {
    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        long start = System.currentTimeMillis();

        try {
            return invocation.proceed();
        } finally {
            log.info("监控 - Begin By AOP");
            log.info("方法名称：{}", invocation.getMethod());
            log.info("方法耗时：{} ms", System.currentTimeMillis() - start);
            log.info("监控 - End");
        }


    }
}
